package com.sjksy.demo.controller;

import com.sjksy.demo.domain.Branch;
import com.sjksy.demo.domain.EmployeeType;
import com.sjksy.demo.service.BranchService;
import com.sjksy.demo.service.EmployeeService;
import com.sjksy.demo.service.EmployeeTypeService;
import com.sjksy.demo.service.GuideService;
import com.sjksy.demo.service.impl.BranchServiceImpl;
import com.sjksy.demo.service.impl.GuideServiceImpl;
import com.sjksy.demo.vo.employee.EmployeeRequestVo;
import com.sjksy.demo.vo.employee.EmployeeResponseVo;
import com.sjksy.demo.vo.employee.GuideVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/employee")
@Tag(name = "员工管理接口",description = "处理员工，导游的增改查操作")
public class EmployeeController {
    @Resource
    private EmployeeService employeeService;
    @Resource
    private GuideService guideService;
    @Resource
    private EmployeeTypeService employeeTypeService;

    @PostMapping("/insert")
    @Operation(summary = "插入员工信息")
    ResponseEntity<String> insert(@RequestBody EmployeeRequestVo employeeRequestVo){
        employeeService.insert(employeeRequestVo);
        return ResponseEntity.ok("插入成功");
    }

    @DeleteMapping("/deleteById/{id}")
    @Operation(summary = "删除员工")
     ResponseEntity<String> update(@PathVariable(name = "id") Integer id){
        employeeService.delete(id);
        return ResponseEntity.ok("删除成功");
    }

    @GetMapping("/all")
    @Operation(summary ="查询所有员工信息")
    ResponseEntity<List<EmployeeResponseVo>> searchAll(){
         List<EmployeeResponseVo> list= employeeService.searchAll();
         return ResponseEntity.ok(list);

    }
    @GetMapping("/guides")
    @Operation(summary = "获取所有导游信息")
    ResponseEntity<List<GuideVo>> searchGuide(){
        List<GuideVo> list= guideService.searchGuide();
        return ResponseEntity.ok(list);
    }

    @GetMapping("/types")
    @Operation(summary = "获取所有员工类型")
    ResponseEntity<List<EmployeeType>> getTypes(){
        List<EmployeeType> all = employeeTypeService.getAll();
        return ResponseEntity.ok(all);
    }

}
